Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
Is there a way to compare "\x3C!--" with "<!--" and get 'true' in JavaScript?

In one of my projects I have to parse HTML pages and to check if each parsed "tag candidate" is in the predefined list of tag defining strings.

The problem emerges when for some reason the parser returns "\x3C!--" as the "tag candidate", so I get false when comparing it with "<!--" from the list.

Is there any way to get true comparing those strings?

UPDATE:

To clarify my question and to explain where the error occurs I add two screenshots from DevTools panel, Google Chrome, version 104.0.5083.0 (Official Build) dev (64-bit).

Paused in debugger 1

We can see that the value of nodeParse.tagOpening is changed almost immediately after it has been assigned. It's quite strange.

Paused in debugger 2

But it's even more strange that if I open properties of nodeParse object in Local Scope, the correct (initially assigned) value is shown for tagOpening.

So it seems the browser knows that both shown values are actually equivalent, but for some reason distinguishes them. Any comments?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Within a HTML document <!-- is the opening delimiter for comments, even within <script> tags, see HTML-like Comments, so I would avoid including it as a string in your code.

Instead, you could just use the hex escape sequence in the tag-defining string in the first place. For example:

nodeParse.tagOpening = '\x3C!--';
nodeData.tagStarter = '\x3C!--';
about 4 years ago · Juan Pablo Isaza Denunciar

0

After a deeper investigation I have revealed that "\x3C!--" == "<!--" is always true, with no extra efforts (see the screenshot below).

We should keep in mind however that string "<!--" (and any longer one) is stored as is in a variable, but is transformed into "\x3C!--" when is stored in an object's property. At least in Google Chrome.

So we should assign the object's property to a variable (like var s2 = ob.a;), if we want to get value "<!--" back for sure. It was not known to me, so I have made a mistake in my code.

Paused in debugger 3

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda